package com.example.administrator.yuejian_15.activity;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.yuejian_15.R;
import com.example.administrator.yuejian_15.bean.JlbBean;
import com.example.administrator.yuejian_15.listener.TListener;
import com.example.administrator.yuejian_15.model.JlbInfoModel;
import com.example.administrator.yuejian_15.service.Service;
import com.squareup.picasso.Picasso;

public class JlbInfoActivity extends BaseActivity implements View.OnClickListener{
    String jlbid;
    ImageView jlbinfo_img;
    TextView jlbinfo_name;
    TextView jlbinfo_phone;
    TextView jlbinfo_address;
    TextView jlbinfo_intro;
    ImageView jlbinfo_fh;

    LinearLayout jlbinfo_jl,jlbinfo_kc,jlbinfo_sp;

    @Override
    void initView() {
        setLayout_file(R.layout.activity_jlb_info);

        jlbid = getIntent().getStringExtra("jlbid");
        jlbinfo_img=(ImageView)findViewById(R.id.jlbinfo_img);
        jlbinfo_name=(TextView)findViewById(R.id.jlbinfo_name);
        jlbinfo_phone=(TextView)findViewById(R.id.jlbinfo_phone);
        jlbinfo_intro=(TextView)findViewById(R.id.jlbinfo_intro);
        jlbinfo_address=(TextView)findViewById(R.id.jlbinfo_address);
        jlbinfo_fh=(ImageView)findViewById(R.id.jlbinfo_fh);

        jlbinfo_jl=(LinearLayout)findViewById(R.id.jlbinfo_jl);
        jlbinfo_kc=(LinearLayout)findViewById(R.id.jlbinfo_kc);
        jlbinfo_sp=(LinearLayout)findViewById(R.id.jlbinfo_sp);

        JlbInfoModel jlbInfoModel = new JlbInfoModel();
        jlbInfoModel.getJulebuInfo(jlbid,jlbBeanTListener);
    }

    @Override
    void initEvent() {
        jlbinfo_fh.setOnClickListener(this);
        jlbinfo_jl.setOnClickListener(this);
        jlbinfo_kc.setOnClickListener(this);
        jlbinfo_sp.setOnClickListener(this);
    }

    @Override
    void initDate() {


    }

    TListener<JlbBean> jlbBeanTListener = new TListener<JlbBean>() {
        @Override
        public void onResponse(JlbBean jlbBean) {
            String jlbname = jlbBean.getJlbname();
            String jlbphone = jlbBean.getJlbphone();
            String jlbintro = jlbBean.getJlbintro();
            String jlbaddress = jlbBean.getJlbaddress();
            String jlbimg = Service.BASE_URL+"yuejian/public/static/jlbimg/jlbinfoimg/"+jlbBean.getJlbpic();

            jlbinfo_name.setText(jlbname);
            jlbinfo_phone.setText("电话："+jlbphone);
            jlbinfo_address.setText("地址："+jlbaddress);
            jlbinfo_intro.setText("介绍："+jlbintro);
            Picasso.with(JlbInfoActivity.this).load(jlbimg).into(jlbinfo_img);

        }

        @Override

        public void onFail(String msg) {

        }
    } ;

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.jlbinfo_fh:
                finish();
                break;
            case R.id.jlbinfo_jl:
                Intent intent = new Intent(JlbInfoActivity.this,JlbJlActivity.class);
                intent.putExtra("jlbid",jlbid);
                startActivity(intent);
                break;
            case R.id.jlbinfo_kc:
                Intent intent1 = new Intent(JlbInfoActivity.this,JlbKcActivity.class);
                intent1.putExtra("jlbid",jlbid);
                startActivity(intent1);
                break;
            case R.id.jlbinfo_sp:
                Intent intent2 = new Intent(JlbInfoActivity.this,JlbSpActivity.class);
                intent2.putExtra("jlbid",jlbid);
                startActivity(intent2);
                break;


        }
    }
}
